package com.gitee.sparta.common.exception;

import com.gitee.sparta.common.SpartaErrorEnum;
import lombok.Getter;

import java.io.Serializable;

/**
 * sparta 内部最顶层的异常，子业务请继承本类，业务中不允许直接使用本异常
 *
 * @author zyred
 * @since v 0.0.1
 */
@Getter
public class SpartaException extends RuntimeException implements Serializable {
    private static final long serialVersionUID = -3081640630685356815L;

    private final Integer code;

    public SpartaException(SpartaErrorEnum errorEnum) {
        super(errorEnum.getMessage());
        this.code = errorEnum.getCode();
    }


    public SpartaException(String message) {
        super(message);
        this.code = 0;
    }

    public SpartaException(Throwable cause) {
        super(cause);
        this.code = 0;
    }
}
